package com.example.eureka.client.eurekaclient.rabbitMq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Produce {
    private static final String QUEUE_NAME = "rabbitMQ.test";

    public static void main(String[] args)throws IOException,TimeoutException{
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("localhost");
//        factory.setUsername("lp");
//        factory.setPassword("1212");
//        factory.setPort(2088);
        Connection chan = factory.newConnection();
        Channel channel = chan.createChannel();
        channel.queueDeclare(QUEUE_NAME,true,false,false,null);
        String message = "Hello RabbitMQ";
        channel.basicPublish("",QUEUE_NAME,null,message.getBytes("UTF-8"));
        System.out.println("producer send+"+message);
        channel.close();
        chan.close();
    }



}
